<%#
  # WebROaR - Ruby Application Server - http://webroar.in/
  # Copyright (C) 2009  Goonj LLC
  #
  # This file is part of WebROaR.
  #
  # WebROaR is free software: you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # WebROaR is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  #
  # You should have received a copy of the GNU General Public License
  # along with WebROaR.  If not, see <http://www.gnu.org/licenses/>.
  #%>

<% #
=begin 
WebROaR - Ruby Application Server - http://webroar.in/
Copyright (C) 2009  Goonj LLC

This file is part of WebROaR.

WebROaR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

WebROaR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with WebROaR.  If not, see <http://www.gnu.org/licenses/>.
=end
%>

<table width = 95%  align='center'>
  <%if @info and @info['Application Specification']%>
    <tr>
      <th colspan = 11>Application Specifications</th>
    </tr>
    <tr>
      <td class = 'sub_header text_align_center'><b>Application Name</b> </td>
      <td class = 'sub_header text_align_center'><b>Resolver</b> </td>
      <td class = 'sub_header text_align_center' width = '10px'><b>Type</b> </td>
      <td class = 'sub_header text_align_center' width = '10px'><b>Analytics</b> </td>
      <td class = 'sub_header text_align_center' width = '10px'><b>Environment</b> </td>	
      <td class = 'sub_header text_align_center' width = '10%'><b>Minimum Workers</b> </td>
      <td class = 'sub_header text_align_center' width = '10%'><b>Maximum Workers</b> </td>	
      <td class = 'sub_header text_align_center' width = '50px'>&nbsp;</td>	
      <td class = 'sub_header text_align_center' width = '50px'>&nbsp;</td>	
      <td class = 'sub_header text_align_center' width = '50px'>&nbsp;</td>
      <td class = 'sub_header text_align_center' width = '50px'>&nbsp;</td>
    </tr>
    <% @applications.each do |application| %>
    <tr>
        <td><%= application['name'] %></td>
        <td><%= application['baseuri'] %></td>
        <td><%= application['type']%></td>
        <td><%= application['analytics']%></td>
        <td><%= application['environment']%></td>
        <td><%= application['min_worker'] %></td>
        <td><%= application['max_worker'] %></td>
        <td><center><%= link_to 'Edit', :controller => 'application_specification', :action => 'edit_application_form', :id => application['name']%></center></td>
        <td><center><%= link_to_remote 'Stop', {:url => {:controller => 'application_specification', :action=>'stop_application', :id => application['name']}, :before => "show_busy_div()", :complete => "hide_busy_div(request)", :update => "dummy_div", :confirm=>STOP_APPLICATION_ALERT_MESSAGE, :oncontextmenu => 'return false;' }%></center></td>
        <td><center><%= link_to_remote 'Delete', {:url => {:controller => 'application_specification', :action=>'delete_application', :id => application['name']}, :before => "show_busy_div()", :complete => "hide_busy_div(request)", :update => "dummy_div", :confirm=>DELETE_APPLICATION_ALERT_MESSAGE, :oncontextmenu => 'return false;' }%></center></td>
        <td><center><%= link_to_remote 'Restart', {:url => {:controller => 'application_specification', :action => 'restart_application', :id => application['name']}, :before => "show_busy_div()", :complete => "hide_busy_div(request)", :update => "dummy_div", :confirm=>RESTART_APPLICATION_ALERT_MESSAGE, :oncontextmenu => 'return false;'}%></center></td>
    </tr>
    <% end %>
    <tr>
      <td colspan = 11 style="text-align:center;">
        ( <%= @applications.offset + 1 %> to <%= @applications.size + @applications.offset %> of <%= @applications.total_entries %> )
      </td>
    </tr>
    <% if will_paginate @applications %>
      <tr>
        <td colspan=11>
          <%= will_paginate @applications ,:params => {:controller => 'admin', :action => 'required_apps'} %>
        </td>
      </tr>
    <% end %>
    <tr>
      <td colspan = 11 style="text-align:right;"><%=link_to 'Add Application', :controller => 'application_specification', :action => 'add_application_form'%></td>
    </tr>
  <%else%>
    <tr>
      <th colspan = 9>&nbsp;</th>
    </tr>
    <tr>
      <td colspan = 9 style="text-align:center;"><%=NO_DEPLOYED_APPLICATION_MESSAGE%></td>
    </tr>
    <tr>
      <td colspan = 9 style="text-align:right;"><%=link_to 'Add Application', :controller => 'application_specification', :action => 'add_application_form'%></td>
    </tr>
  <%end%>
</table>	
